package com.huabo.contract.service.impl;

import com.huabo.contract.config.DateBaseConfig;
import com.huabo.contract.oracle.entity.TblFlow;
import com.huabo.contract.oracle.entity.TblFormControllog;
import com.huabo.contract.oracle.mapper.TblFlowMapper;
import com.huabo.contract.service.TblFlowService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;

@Service
public class TblFlowServiceImpl implements TblFlowService {

    @Resource
    private TblFlowMapper tblFlowMapper;

    @Override
    public TblFlow findById(String flowid) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            return this.tblFlowMapper.findByFlowid(flowid);
        } else {
            return this.tblFlowMapper.findByFlowid(flowid);
        }
    }

    @Override
    public TblFlow findByFlowid(String flowid) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            return tblFlowMapper.findByFlow(flowid);
        } else {
            return tblFlowMapper.findByFlow(flowid);
        }
    }

    @Override
    public TblFlow findBy(String flowid) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            return tblFlowMapper.findByFlow(flowid);
        } else {
            return tblFlowMapper.findByFlow(flowid);
        }
    }

    @Override
    public TblFlow findByFlow(BigDecimal flowid) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            return tblFlowMapper.findFlowid(flowid);
        } else {
            return tblFlowMapper.findFlowid(flowid);
        }
    }

    @Override
    public void saveTfl(TblFormControllog tfl) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            tblFlowMapper.saveTfl(tfl);
        } else {
            tblFlowMapper.saveTfl(tfl);
        }
    }

    @Override
    public void updateTfl(TblFormControllog tfl) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            tblFlowMapper.updateTfl(tfl);
        } else {
            tblFlowMapper.updateTfl(tfl);
        }
    }

    @Override
    public String findMappingUrl(BigDecimal flowId) {
        if(DateBaseConfig.DATABASETYPE.equals("Oracle")) {
            return tblFlowMapper.selectFlowid(flowId);
        } else {
            return tblFlowMapper.selectFlowid(flowId);
        }
    }
}
